package gamagora.game.entity
{
	import gamagora.game.utils.effect.Displacement;
	import gamagora.game.utils.effect.FXGroup;

	public class OSBlurEffect extends OSEntity
	{
		private var _effectEmitter:Displacement;
		private var _group:FXGroup;
		
		private var _effectWidth:Number;
		private var _effectHeight:Number;
		private var _effectXSpeedMin:Number;
		private var _effectXSpeedMax:Number;
		private var _effectYSpeedMin:Number;
		private var _effectYSpeedMax:Number;
		private var _effectBlobWidth:Number;
		private var _effectBlobHeight:Number;
		private var _effectDisplaceAmtX:Number;
		private var _effectDisplaceAmtY:Number;
		private var _effectAlpha:Number;
		private var _effectLife:Number;
		private var _effectBlobCount:uint;
		
		public function OSBlurEffect(X:Number=0, Y:Number=0, w:Number = 0, h:Number = 0)
		{
			super(NOTHING, X, Y);
			setSize(w, h);
			_hide = true;
		}
		
		public override function setStartX(decalX:Number):void
		{
			x += decalX;
			_startX += decalX;
			
			_group = new FXGroup();
			_group.add(_effectEmitter = new Displacement(_group.FXBuffer, x, y));
			_effectEmitter.setSize(_effectWidth, _effectHeight);
			_effectEmitter.setXSpeed(_effectXSpeedMin, _effectXSpeedMax);
			_effectEmitter.setYSpeed(_effectYSpeedMin, _effectYSpeedMax);
			_effectEmitter.blobHeight = _effectBlobHeight;
			_effectEmitter.blobWidth = _effectBlobWidth;
			_effectEmitter.displaceAmtX = _effectDisplaceAmtX;
			_effectEmitter.displaceAmtY = _effectDisplaceAmtY;
			_effectEmitter.alpha = _effectAlpha;
			_effectEmitter.life = _effectLife;
			_effectEmitter.blobCount = _effectBlobCount;
			_effectEmitter.begin();
		}
		
		public override function update():void
		{
			_group.update();
		}
		
		public override function draw():void
		{
			_group.draw();
		}
		
		public override function destroy():void
		{
			super.destroy();
			_group.destroy();
			_effectEmitter.destroy();
		}
		
		//Delegates
		
		public function setSize(w:Number, h:Number):void
		{
			_effectWidth = w;
			_effectHeight = h;
		}
		
		public function setXSpeed(xMin:Number, xMax:Number):void
		{
			_effectXSpeedMin = xMin;
			_effectXSpeedMax = xMax;
		}
		
		public function setYSpeed(yMin:Number, yMax:Number):void
		{
			_effectYSpeedMin = yMin;
			_effectYSpeedMax = yMax;
		}

		public function get effectBlobWidth():Number
		{
			return _effectBlobWidth;
		}

		public function set effectBlobWidth(value:Number):void
		{
			_effectBlobWidth = value;
		}

		public function get effectBlobHeight():Number
		{
			return _effectBlobHeight;
		}

		public function set effectBlobHeight(value:Number):void
		{
			_effectBlobHeight = value;
		}

		public function get effectDisplaceAmtX():Number
		{
			return _effectDisplaceAmtX;
		}

		public function set effectDisplaceAmtX(value:Number):void
		{
			_effectDisplaceAmtX = value;
		}

		public function get effectDisplaceAmtY():Number
		{
			return _effectDisplaceAmtY;
		}

		public function set effectDisplaceAmtY(value:Number):void
		{
			_effectDisplaceAmtY = value;
		}

		public function get effectAlpha():Number
		{
			return _effectAlpha;
		}

		public function set effectAlpha(value:Number):void
		{
			_effectAlpha = value;
		}

		public function get effectLife():Number
		{
			return _effectLife;
		}

		public function set effectLife(value:Number):void
		{
			_effectLife = value;
		}

		public function get effectBlobCount():uint
		{
			return _effectBlobCount;
		}

		public function set effectBlobCount(value:uint):void
		{
			_effectBlobCount = value;
		}
	}
}
